﻿<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*" %>
<%@ page import="com.sms.user.*" %>

<%--
	people/teacher/project.jsp
 --%>

<%	//清除内存
	response.setHeader("Pragma","No-cache"); 
	response.setHeader("Cache-Control","no-cache"); 
	response.setDateHeader("Expires", 0); 
%> 

<%
	request.setCharacterEncoding("utf-8");
	String userno = (String)session.getAttribute("userno");
	String role = (String)session.getAttribute("role");
%>

<%
	String type = request.getParameter("stutype");
	String select[] = new String[4];
	if(type != null) {
		if(type.trim().equals("all")) {
			select[0] = "selected";
		} else if(type.trim().equals("front")){
			select[1] = "selected";
		} else if(type.trim().equals("back")){
			select[2] = "selected";
		} else {
			select[3] = "selected";
		}
	} else {
			select[0] = "selected";
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<br/>
<a class="easyui-linkbutton" id="add-people" iconCls="icon-add">添加人员</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a class="easyui-linkbutton" id='cut-people' iconCls="icon-cut">删除人员</a><!--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
指导老师:<select id="teacher" style="width:80px">
	<option value="全部">全部</option>
		</select>-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
学员类型:<select id="stutype" style="width:80px" >
	<option value="all" <%= select[0] %>>全部</option>
	<option value="front" <%= select[1] %>>前台</option>
	<option value="back" <%= select[2] %> >后台</option>
	<option value="ps" <%= select[3] %> >美工</option>
	</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" id="people-search"  value="搜索"/>
<br/>
<form onSubmit="return false" id="all-project">
<table class="people" cellpadding="0" cellspacing="0">
</table>
</form>
<div id="dd"></div>
<div id="aa"></div>
<script type="text/javascript">
$.ajaxSetup({
	dataType:'html',
	cache:false
	})

$('.people').datagrid({
	url:'GetStudentServlet?stutype=' + $('#stutype').attr('value'), //返回数据的链接
	idField:'sno',
	pagination:true,
	columns:[[
			{field:'cut',checkbox:true },
			{field:'sno',title:'学号',width:100},
			{field:'sname',title:'姓名',width:100},
			{field:'sex',title:'性别',width:100},
			{field:'major',title:'专业',width:100},
			{field:'teacher',title:'指导老师',width:100},
			{field:'type',title:'学员类型',width:100},
			{field:'number',title:'参与项目数',width:100},
			
		]]
})

/*添加处理*/
 $("#add-people").click(function(){
			$('#dd').dialog({
			         title:"添加人员",
					 width:800, height:500,
					 cache:false,
					 top:100,left:200,
					 cache:false,
					 href:'people/headman/add-people.jsp' 
					 });
			$('#dd').dialog('refresh','people/headman/add-people.jsp' );
		
})


/*删除处理*/
 var selectRow=$('.people').datagrid('getRowIndex');
$("#cut-people").click(function(){
       var ids=[];
        var rows = $('.people').datagrid('getSelections'); 
		if (!rows || rows.length == 0) {
         $.messager.alert('提示', '请选择要删除的数据!', 'info');return;}  
      $.each(rows, function (i, n) {
     ids.push(n.sno);
});
$.messager.confirm('提示', '是否删除选中数据?', function (r) {
if (!r) {
return;
} 
//alert(ids);
$.ajax({
		   url:'people/headman/del-people.jsp',       /*删除处理界面,传到后台的是所有选中的行号组成的数字数组*/
		   data:'selectrows='+ids,
		   dataType:'text',
		   success:function(msg){
			   if(msg=='ok'){
				   alert("删除成功");
			 	  	var tab = $(".easyui-tabs").tabs('getSelected');
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									 options:{
								     cache:false,
                                     href:'people/headman/people.jsp?type=' + $('#stutype').attr('value')
									 }
									}
									);  /*更新面板*/

				   } 
          		else{
					alert("删除失败");
					}
				}
			  
		   })
})
		  })
	
/*搜索处理*/
$("#people-search").click(function(){
	var tab = $(".easyui-tabs").tabs('getSelected');;
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									options:{
								      cache:false,
                                    href:'people/headman/people.jsp?stutype=' + $('#stutype').attr('value')
									 }
									}
									);  /*更新面板*/	
		
	})
</script>
</body>
</html>